#include "system_config_info.h"
#include "sqlite_manager.h"
#include "easylogging++.h"

SystemConfigInfo::SystemConfigInfo()
{

}

bool SystemConfigInfo::getRequirementStatusInfo(QJsonObject *requirementStatusInfo)
{
    SqliteManager sm;
    if (nullptr == requirementStatusInfo)
    {
        LOG(ERROR) << "requirementStatusInfo is nullptr!";
        return false;
    }

    QList<QVariantList> data;
    bool ret = sm.selectData("system_config_info",
                             {"config_key", "config_value", "config_description"},
                             {{"config_group", "requirement_status"}},
                             data);
    if (!ret)
    {
        LOG(ERROR) << "select requirement status info from db failed! error info: "
                   << sm.lastError().toStdString();
        return false;
    }

    for (int i = 0; i < data.count(); i++)
    {
        QJsonObject item;
        item["requirement_status"] = data[i][1].toString();
        item["requirement_description"] = data[i][2].toString();
        (*requirementStatusInfo)[data[i][0].toString()] = item;
    }

    return true;
}
